/*
 * Android Runner is a multiplayer GPS game fully written by Xurxo Mendez Perez
 * 
 * Copyright (C) 2009 Xurxo Mendez Perez
 *   
 * This file is part of Android Runner.
 * 
 * Android Runner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Android Runner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Android Runner.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.sonxurxo.androidrunner.model.persistence.game.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;

import es.sonxurxo.androidrunner.model.persistence.player.entity.Player;

/**
 * 
 * @author "Xurxo Mendez Perez"
 *
 */
@Entity
public class FinishedGameRegister {

	private long finishedGameRegisterId;
	private Player player;
	private Game game;
	private int position;
	private int points;
	private int numberOfItems;
	
	public FinishedGameRegister() {
		super();
	}
	
	public FinishedGameRegister(Player player, Game game, int position, int points, int numberOfItems) {
		super();
		this.player = player;
		this.game = game;
		this.position = position;
		this.points = points;
		this.numberOfItems = numberOfItems;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "gameId")
	public Game getGame() {
		return game;
	}

	public void setGame(Game game) {
		this.game = game;
	}

	@Id
	@Column(name = "fgrId")
	@GeneratedValue(strategy=GenerationType.AUTO,
            generator="FGRIdGenerator")
    @SequenceGenerator(             // It only takes effect for
            name="FGRIdGenerator", // databases providing identifier
            sequenceName="FGRSeq") // generators.
	public long getFinishedGameRegisterId() {
		return finishedGameRegisterId;
	}

	public void setFinishedGameRegisterId(long finishedGameRegisterId) {
		this.finishedGameRegisterId = finishedGameRegisterId;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "playerId")
	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}

	public int getPoints() {
		return points;
	}

	public void setPoints(int points) {
		this.points = points;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}
	
	public String toString() {
		return new String("Game = " + this.game +
				" ;Player = " + this.player + " ;position = " + this.position + 
				" ;points = " + this.points);
	}

	public int getNumberOfItems() {
		return numberOfItems;
	}

	public void setNumberOfItems(int numberOfItems) {
		this.numberOfItems = numberOfItems;
	}
}
